package com.hoshiibuy.es.controller;

import com.google.gson.Gson;
import com.hoshiibuy.es.entity.Employee;
import com.hoshiibuy.es.repository.EmployeeRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @author WGJ
 */
@RestController
@RequestMapping("/es")
@Api(value = "同步商品到es管理", tags = {"同步商品到es基本操作接口"})
public class EmployeeController {
 
   /* @Autowired
    private EmployeeRepository employeeRepository;
 
    *//**
     * 添加
     * @return
     *//*
    @GetMapping("/add")
    @ApiOperation(value = "查询",
            notes = "根据名称查询公司用户基本信息",
            produces = "application/json, application/xml",
            consumes = "application/json, application/xml")
    public String add() {
        Employee employee = new Employee();
        employee.setId("2");
        employee.setFirstName("xuxu");
        employee.setLastName("zh");
        employee.setAge(26);
        employee.setAbout("i am in peking");
        employeeRepository.save(employee);
        System.err.println("add a obj");
        return "success";
    }
 
    *//**
     * 删除
     * @return
     *//*
    @GetMapping("/delete")
    public String delete() {
        Employee employee = employeeRepository.queryEmployeeById("2");
        employeeRepository.delete(employee);
        return "success";
    }
 
    *//**
     * 局部更新
     * @return
     *//*
    @GetMapping("/update")
    public String update() {
        Employee employee = employeeRepository.queryEmployeeById("2");
        employee.setFirstName("哈哈");
        employeeRepository.save(employee);
        System.err.println("update a obj");
        return "success";
    }
    *//**
     * 查询
     * @return
     *//*
    @GetMapping("/query")
    public Employee query() {
        Employee accountInfo = employeeRepository.queryEmployeeById("2");
        System.err.println(new Gson().toJson(accountInfo));
        return accountInfo;
    }*/
}  